
   const createMap = function (srcKey, destKey) {
        let that = this, combineKey = srcKey + "->" + destKey;
        if (!that.profiles.hasOwnProperty(combineKey)) that.profiles[combineKey] = {};

        let funcs = {
            forMember: function (prop, any) {
                that.profiles[combineKey][prop] = any;
                return funcs;
            }
        };
        return funcs;
    };

    const map = function (srcKey, destKey, srcObj, destObj) {
        let that = this, combineKey = srcKey + "->" + destKey;
        if (!that.profiles.hasOwnProperty(combineKey)) throw "Could not find mapping with a source of " + srcKey + " and a destination of " + destKey;
        let profile = that.profiles[combineKey];
        for (let prop in destObj) {
            if (!profile.hasOwnProperty(prop)) destObj[prop] = srcObj.hasOwnProperty(prop) ? srcObj[prop] : destObj[prop];
            else {
                let output = profile[prop];
                if (typeof output === "function") destObj[prop] = output(srcObj, destObj);
                else destObj[prop] = output;
            }
        }
    };
	
	const  AutoMapper = {
	    profiles:{},
	    version :'1.0.0',
		createMap,
		map
	};

export default  AutoMapper
